#pragma once
#include "StdAfx.h"

class MeshDesc
	:public GameResourceDesc
{
};
class SubMesh : public Base
{
public:
	SubMesh(BaseDesc &desc):Base(desc){};
	~SubMesh()
	{
		glDeleteLists(DrawList, 1);
		glDeleteLists(DebugDrawList, 1);
	};
	std::vector<Vec3> Vertices, Normals, Tangents, Bitangents, TexCoords;
	std::vector<unsigned int> Indices;
	GLuint DrawList, DebugDrawList;
};
class Mesh :
	public GameResource
{
public:
	Mesh(GameResourceDesc &desc):GameResource(desc){};
	Mesh(MeshDesc&);
	~Mesh(void);
	BBVector<sptr<SubMesh>> SubMeshes;
	virtual void LoadFromFile();
	virtual void SaveToFile();
	void Draw(unsigned int subMeshId);
	void Draw();
	void DebugDraw();
	void DebugDraw(unsigned int subMeshId);
	float GetRadius();
	Vec3 vmin, vmax;
private:
	float Radius;
	void DrawSubmesh(unsigned int subMeshId);
	void DebugDrawSubmesh(unsigned int subMeshId);
	void LoadASE();
	void CalculateNormals();
	void InitLists();
};

